/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package OilSimNoteBook;

import java.awt.Container;
import java.awt.Dimension;
import java.util.Observable;
import javax.swing.JFrame;
import javax.swing.JPanel;


public abstract class OilSimUIComponent extends Observable {

    private String title = OilSimUIComponent.class.getSimpleName();
    protected JFrame frame;

    public abstract Container getPanel();

    public String getTitle() {
        return title;
    }

    public JFrame getFrame() {
        if (frame == null) {
            frame = new JFrame(getTitle());
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setContentPane(getPanel());
            //frame.setPreferredSize(new Dimension(700, 400));
            frame.pack();
        }
        return frame;
    }

    public JFrame showFrame() {
        frame = getFrame();
        frame.setVisible(true); // frame made to be visible
        return frame;
    }
}
